// 获取天气，返回数据不是promise数据所以改为promise数据目的：实现异步请求防止后面代码不执行
import jsonp from "jsonp";
export function reqWeather(city){
    const url = `https://www.yiketianqi.com/free/day?appid=16168584&appsecret=Ei79WR0E&city=${city}`
    return new Promise((resolve)=>{
        jsonp(url,{
            param:'callback'
        },(error,response)=>{
            // console.log(response);
            // console.log(reject);
            if(!error && response.cityid){
                const{tem_day,tem_night,wea,wea_img} = response
                resolve({tem_day,tem_night,wea,wea_img})
            }else{
                alert('获取天气失败');
            }
        })
    })
}